/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2021-09-17
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
#ifndef _LS_BLE_FILE_API_H_
#define _LS_BLE_FILE_API_H_

/*----------------------------Head file----------------------------*/
#include "stdint.h"
#include "ls_ble_sdk_config.h"

/*----------------------------macro file---------------------------*/
#define BLE_FILE_SUCCESS     0

/*----------------------------type define--------------------------*/
typedef enum {
    LS_BLE_FILE_CB_EVT_NULL = 0,
    
    LS_BLE_FILE_CB_EVT_DISCONNECT,
    
    LS_BLE_FILE_CB_EVT_NTF_ENABLE,
    LS_BLE_FILE_CB_EVT_NTF_DISABLE,
    LS_BLE_FILE_CB_EVT_NTF_COMPLETE,
    
    LS_BLE_FILE_CB_EVT_RX_CMD_PAYLOAD,
    LS_BLE_FILE_CB_EVT_RX_FILE_DATA,
    
} ls_ble_file_cb_evt_t;

typedef enum {
    FILE_TYPE_NULL         = 0,
    FILE_TYPE_TEXT,
    FILE_TYPE_OTA,
    FILE_TYPE_IMG,
} file_type_t;

typedef struct {
    bool running;
    uint8_t file_type;
    uint32_t offset;
} file_trans_t;

typedef struct {
    ls_ble_file_cb_evt_t evt;
    uint8_t cmd;
    uint8_t *p_data;
    uint16_t len;
} ls_ble_file_cb_evt_param_t;


typedef enum {
    FILE_CMD_NULL         = 0,
    FILE_CMD_TEXT_INFO    = 0x01,
    FILE_CMD_OTA_INFO     = 0x02,
    FILE_CMD_IMG_INFO     = 0x03,
    
    FILE_CMD_TRANS_DONE   = 0x10,
    FILE_CMD_TRANS_RSP_EN = 0x11,
    
    FILE_CMD_RECV_DATA_LEN= 0x80,

} file_cmd_t;


typedef enum {
    FILE_DONE_SUCCESS     = 0,
    FILE_DONE_CRC_ERR,
    FILE_DONE_SIZE_ERR,
    FILE_DONE_CONTENT_ERR,
} file_done_rsp_err_t;

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/
extern void ls_ble_file_callback(ls_ble_file_cb_evt_param_t* param);

/*-----------------------------------------------------------------*/

#endif
